<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .page {
            display: flex;
            list-style: none;
            padding:  0;
            margin: 0;
        }

        .page li {
            width: 30px;
            height: 30px;
            text-align: center;
            line-height: 30px;
            border: 1px solid #ddd;
            box-sizing: border-box;
        }

        .active {
            background: red;
        }
    </style>
</head>
<body>
    <div id="app">
        <input type="text" v-model="inpValue">

        <button @click="append" type="">append</button>

        <ul>
            <li v-for="item in arr">{{item}}</li>
        </ul>

        <ul class="page">
            <li
                v-for="item in Math.ceil(arr.length / 5)"
                @click="changePageIndex(item)"
                :class="{'active': item === pageIndex}">
                {{item}}
            </li>
        </ul>
    </div>

    <script src="./vue.js"></script>
    <script>
        // 数据驱动
        let myApp = new Vue({
            el: '#app',
            data: {
                inpValue: '',
                arr: [],
                pageIndex: 0
            },
            methods: { 
                append () {
                    this.arr.push(this.inpValue)

                    this.inpValue = ''
                },
                changePageIndex (pageIndex) {
                    console.log(pageIndex)

                    this.pageIndex = pageIndex
                }
            }
        })
    </script>
</body>
</html>